# -*- coding: utf-8 -*- 
"""
========================================================================================================================
@project : my-sanic
@file: myResFormat
@Author: mengying
@email: 652044581@qq.com
@date: 2023/3/3 12:14
@desc: 返回的数据格式定义
========================================================================================================================
"""
from enum import Enum, unique
from addict import Dict


@unique
class ResultCode(Enum):
    """(code返回码, msg信息， description描述)"""
    SUCCESS = ('0000', '操作成功', None)


class ResultJson:
    result = Dict()

    def __init__(self, ret=ResultCode.SUCCESS, data=None, description=None):
        self.result.code = ret.value[0]
        self.result.msg = ret.value[1]
        self.result.data = data
        self.result.description = description or ret.value[2]


if __name__ == '__main__':
    print(ResultJson(ret=ResultCode.SUCCESS, data=None, description="成功").result)
